package com.persia.tool;


import com.persia.exception.AppException;
import com.persia.exception.ProgramException;

/**
 * 统一异常处理
 * e和cause容易混杂掉
 * @author: caibosi
 * @created: 2013-12-14
 */
public class ExceptionTool {

    public static void transformException(Throwable throwable){
        if(throwable instanceof AppException){
            throw (AppException)throwable;
        }else if(throwable.getCause() instanceof AppException){
            throw (AppException)throwable.getCause();
        }else{
            throw new ProgramException(throwable);
        }
    }

}
